<template>
    <div>
        <ve-line :data="chartData"></ve-line>
    </div>
</template>

<script>
    import axios from 'axios'
    export default {
        name: "DayConformTend",
        data: function () {
            return {
                countData:null,
                countDayAddList:null,
            }
        },
        computed: {
            drCountData: {

                get(){
                    return this.$store.state.drCountData;
                },
                set(v) {
                    this.countData = v
                }

            },
            dayTotalList: {
                get() {
                    return this.drCountData.china_day_total_list;
                },
                set(v) {
                    this.countDayAddList = v
                }

            },
            chartData(){
                return {
                    columns: ['日期', '确诊病例', '疑似病例'],
                    rows: this.getRowsData()
                }
            }

        },
        created(){
        },
        methods:{
            getRowsData(){
                let rows = [];
                if(this.dayTotalList === undefined){
                    this.getLineData();
                }else{
                    let dates = this.dayTotalList.date;
                    let confirmTotal = this.dayTotalList.confirm_total;
                    let suspectTotal = this.dayTotalList.suspect_total;
                   /* let healTotal = this.dayTotalList.heal_total;
                    let deadTotal = this.dayTotalList.dead_total;*/

                    dates.forEach((item,i) => {
                        let row =  { '日期': dates[i], '确诊病例': confirmTotal[i], '疑似病例': suspectTotal[i]};
                        rows.push(row)
                    })
                }

                return rows ;

            },
            getLineData(){
                axios.post('https://ncov.zhhainiao.com/ncov/data/get')
                    .then(response => {
                        // this.$store.commit('drData', response.data.ncov_data);
                        this.drCountData = response.data.ncov_data;
                        this.dayTotalList = response.data.ncov_data.china_day_total_list;
                    })
            }
        }
    }
</script>

<style scoped>

</style>